<!-- 预定 -->
<template>
  <view class="fix_piao">
    <view class="fix_top"></view>
    <view class="fix_bottom">
      <view class="fix_b_left">
        <view class="img">
          <uni-badge :text="byAllPiaoNum" absolute="rightTop" :offset="[3, 3]">
            <image :src="userInfo.avatar" />
          </uni-badge>
        </view>
        <view class="left_right">
          <view class="all_num">
            <span class="span1">￥</span>
            <span class="span2">{{ allPrice }}</span>
          </view>
          <view class="text">实付金额</view>
        </view>
      </view>
      <view class="fix_b_right">
        <view class="b_r_left" v-if="isDesc">
          <uni-icons type="help-filled" color="#1C96FF" size="16"></uni-icons>
          <text @click="ticketDescription">票务说明</text>
        </view>
        <view class="b_r_right">
          <u-button
            :text="btnTitle"
            @click="toPayPrice"
            shape="circle"
            color="#0E9589"
            size="mini"
            :disabled="!allPrice"
          ></u-button>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    // 购买的总个数
    byAllPiaoNum: {
      type: Number,
    },
    // 总价格
    allPrice: {
      type: Number,
    },
    // 按钮名称
    btnTitle: {
      type: String,
    },
    // 是否显示票务说明
    isDesc: {
      type: Boolean,
    },
  },
  data() {
    return {
      userInfo: {},
    };
  },

  mounted() {
    this.getUserInfo();
  },

  methods: {
    // 票务说明
    ticketDescription() {
      this.$emit("ticket-desc");
    },

    // 跳转支付页面
    toPayPrice() {
      this.$emit("to-pay");
    },
    // 获取用户信息
    getUserInfo() {
      this.userInfo = JSON.parse(uni.getStorageSync("userInfo"));
      console.log(this.userInfo);
    },
  },
};
</script>

<style lang="scss" scoped>
.fix_piao {
  width: 750rpx;
  height: 132rpx;
  position: fixed;
  z-index: 1000 !important;
  bottom: 0;
  left: 0;
  right: 0;

  .fix_top {
    width: 100%;
    height: 20rpx;
    background: #f3f3f3;
  }

  .fix_bottom {
    height: 112rpx;
    width: 100%;
    padding: 0 35rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;

    .fix_b_left {
      height: 100%;
      position: relative;
      border-radius: 50%;
      display: flex;
      align-items: center;

      image {
        width: 80rpx;
        height: 80rpx;
        border-radius: 50%;
      }

      .left_right {
        margin-left: 28rpx;

        .all_num {
          font-size: 28rpx;
          font-weight: 600;
          color: #0e9589;
          line-height: 39rpx;

          .span1 {
            font-size: 20rpx;
          }

          .text {
            font-size: 20rpx;
            font-weight: 400;
            color: #666666;
          }
        }
      }
    }

    .fix_b_right {
      display: flex;
      align-items: center;

      .b_r_left {
        color: #1c96ff;
        display: flex;
        align-items: center;
        margin-right: 20rpx;
      }
    }
  }
}
</style>
